﻿Option Explicit On

Imports System.IO
Imports System.Data.OleDb

Public Class test



    ' Dim WithEvents RecoContext As SpSharedRecoContext

    '  Dim Grammar As ISpeechRecoGrammar

    ' Dim Voice As SpVoice

    ' Dim m_bRecoRunning As Boolean

    'Dim m_cChars As Integer

    Private Sub test_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'LexikoDataSet.english' table. You can move, or remove it, as needed.
        Me.EnglishTableAdapter.Fill(Me.LexikoDataSet.english)
        'TODO: This line of code loads data into the 'LexikoDataSet.greek' table. You can move, or remove it, as needed.
        Me.GreekTableAdapter.Fill(Me.LexikoDataSet.greek)


       
        'SetState(False)

        ' m_cChars = 0

        'Voice = New SpVoice

        ' Timer.Enabled = True


        ' Dim strSQL As String = _
        '  "SELECT * FROM Products WHERE CategoryID = 1"

        ' Try
        'Using adapter As New OleDbDataAdapter(strSQL, _
        'My.Settings.OleDbConnectionString)
        ' Dim dt As New DataTable
        ' adapter.Fill(dt)

        ' For Each dc As DataColumn In _
        'dt.Columns()

        ' demoList.Items.Add( _
        '  String.Format("{0} ({1})", _
        '   dc.ColumnName, dc.DataType))
        ' Next dc

        ' demoGrid.DataSource = dt
        'End Using

        ' Catch ex As Exception
        'MessageBox.Show(ex.Message)
        '  End Try



    End Sub

    Private Sub Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start.Click
        ' Debug.Assert(Not m_bRecoRunning)

        ' Initialize recognition context object and grammar object, then

        ' start dictation

        'If (RecoContext Is Nothing) Then

        'Debug.Print("Initializing SAPI reco context object...")

        ' RecoContext = New SpSharedRecoContext

        ' Grammar = RecoContext.CreateGrammar(1)

        ' Grammar.Dictationload()

        ' End If

        'Grammar.DictationSetState(SGDSActive)

        ' SetState(True)

    End Sub

    Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
        'Debug.Assert(m_bRecoRunning)

        ' Grammar.DictationSetState(SGDSInactive)

        ' SetState(False)
    End Sub
    ' This function handles Recognition event from the reco context object.

    ' Recognition event is fired when the speech recognition engines recognizes

    ' a sequences of words.

    '   Private Sub RecoContext_Recognition(ByVal StreamNumber As Long, ByVal StreamPosition As Object, ByVal RecognitionType As 'SpeechRecognitionType, ByVal Result As ISpeechRecoResult)

    ' Dim strText As String

    ' strText = Result.PhraseInfo.GetText
    '
    'Debug.Print("Recognition: " & strText & ", " & StreamNumber & ", " & StreamPosition)

    ' Append the new text to the text box, and add a space at the end of the

    ' text so that it looks better

    ' txtSpeech.SelStart = m_cChars

    ' txtSpeech.SelText = strText & " "

    ' m_cChars = m_cChars + 1 + Len(strText)

    'Debug.Assert(m_bRecoRunning)

    ' Grammar.DictationSetState(SGDSInactive)

    ' SetState(False)

    ' Voice.Speak(strText)

    ' txtSpeech.Text = ""
    ' Debug.Print("Initializing SAPI reco context object...")

    ' RecoContext = New SpSharedRecoContext

    'Grammar = RecoContext.CreateGrammar(1)

    ' Grammar.Dictationload()

    ' Grammar.DictationSetState(SGDSActive)

    ' SetState(True)

    ' End Sub

    ' This function handles the state of Start and Stop buttons according to

    ' whether dictation is running.

    Private Sub SetState(ByVal bNewState As Boolean)

        ' m_bRecoRunning = bNewState

        ' Start.Enabled = Not m_bRecoRunning

        ' btnStop.Enabled = m_bRecoRunning

    End Sub

    Private Sub Apotelesmata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Apotelesmata.Click
        Me.Hide()
        apotelesmata.Show()
    End Sub



    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub GreekBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GreekBindingNavigatorSaveItem.Click
        ' Me.Validate()
        ' Me.GreekBindingSource.EndEdit()
        'Me.TableAdapterManager.UpdateAll(Me.LexikoDataSet) 
        If SaveChanges() Then
            MessageBox.Show("Your changes were saved", _
              "Greek", MessageBoxButtons.OK)
        End If

    End Sub
  

    Private Sub Easy_wordsLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub GreekBindingNavigator_RefreshItems(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GreekBindingNavigator.RefreshItems

    End Sub

    Private Function SaveChanges() As Boolean
        'na ginoun oi allages sos na doume an xreiazete'
        If ValidateData() Then
            Me.TableAdapterManager.UpdateAll( _
              Me.LexikoDataSet)
            Return True
        End If
        Return False
    End Function

    Private Function ValidateData() As Boolean
        If Me.Validate() Then
            Try
                GreekBindingSource.EndEdit()
                Return True
            Catch ex As Exception
                If MessageBox.Show( _
                  "Invalid data was entered. Cancel edits?", _
                  "Products", MessageBoxButtons.YesNo, _
                  MessageBoxIcon.Error) = DialogResult.Yes Then

                    GreekBindingSource.CancelEdit()
                End If
                Return False
            End Try
        End If
        Return False
    End Function

    
    Private Sub DataValidation_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        'elegxos an trexei kai na ginei kai gia tis alles glwsses SOS'

        If ValidateData() Then
            If Me.LexikoDataSet.greek.GetChanges IsNot Nothing Or Me.LexikoDataSet.english.GetChanges _
                IsNot Nothing Then

                Dim response As Integer = _
                  MessageBox.Show( _
                  "Do you want to save your changes?", _
                  "Changes have been made", _
                  MessageBoxButtons.YesNoCancel, _
                  MessageBoxIcon.Warning)

                If response = DialogResult.Yes Then
                    If SaveChanges() Then
                        MessageBox.Show("Your changes were saved", _
                          "Products", MessageBoxButtons.OK)
                    Else
                        e.Cancel = True
                    End If
                ElseIf response = DialogResult.Cancel Then
                    e.Cancel = True
                End If
            End If
        End If
    End Sub
    Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click
        'check an trexei SOS'

        Easy_wordsTextBox.Focus()
        Easy_wordsTextBox1.Focus()
        If Easy_wordsTextBox.Text = Nothing Then

            Easy_wordsTextBox.Focus()
        ElseIf Easy_wordsTextBox1.Text = Nothing Then
            Easy_wordsTextBox1.Focus()
        End If
    End Sub

    Private Sub Easy_wordsLabel1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Easy_wordsTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Easy_wordsTextBox1.TextChanged

    End Sub

    Private Sub Easy_wordsTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Easy_wordsTextBox.TextChanged

    End Sub
End Class